package acs.bridge.jreport;

import acs.bridge.bm_jreport;
import acs.bridge.dao.Bm_jreportDAOImpl;
import org.apache.tools.ant.util.ReaderInputStream;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.sql.Clob;

/**
 * acs.bridge.jreport
 * User: KuznetsovStV
 * Date: 04.02.14
 * Time: 23:06
 */
public class JReportTemplateDataBase implements JReportTemplateInterface {

    public String module_tag;

    public String getModule_tag() {
        return module_tag;
    }

    public void setModule_tag(String module_tag) {
        this.module_tag = module_tag;
    }

    public String getJreport_tag() {
        return jreport_tag;
    }

    public void setJreport_tag(String jreport_tag) {
        this.jreport_tag = jreport_tag;
    }

    private String jreport_tag;


    @Override
    public InputStream getBinaryStream() throws Exception {
        Clob module_cdata = bm_jreport.getBm_jreportDAOImpl().fnc_get_module_cdata(getModule_tag() == null ? bm_jreport.getModule_tag() : getModule_tag(), getJreport_tag(), "JREPORT");

        return new ReaderInputStream(module_cdata.getCharacterStream(), "UTF-8");


    }

    @Override
    public String getReportName() {
        return getJreport_tag();
    }
}
